# https://www.qttc.net/427-django-crypt.html
from django.conf import settings
from django.utils.encoding import force_bytes
from passlib.handlers.pbkdf2 import pbkdf2_sha256

settings.configure()
from django.contrib.auth.hashers import make_password, check_password

pwd = 'shucangdao123'
mpwd = make_password(pwd, None, 'pbkdf2_sha256')  # 创建django密码，第三个参数为加密算法
print(mpwd)
pwd_bool = check_password(pwd, mpwd)
print(pwd_bool)

db_pwd = "pbkdf2_sha256$260000$o7g1mO3rLbSEKbF9VCVNoP$pCFDqwk6kXmhU0OCsXbVGmC2ZvpCSbWlZjA1OOIdvuM="
print(check_password(pwd, db_pwd))

salt = force_bytes("o7g1mO3rLbSEKbF9VCVNoP")
custom_pbkdf2 = pbkdf2_sha256.using(rounds=260000)
res = custom_pbkdf2.hash(force_bytes(pwd), salt=salt)
print(res)


